package cc.autoapi.pucong.auto.flow.core.flow.execNode.exception;

/**
 * flow 设计 自定义异常类
 */
public class AutoDesignException extends RuntimeException {

    private String code;
    private String[] args;


    /**
     * 根据异常提示，返回异常信息
     *
     * @param code
     */
    public AutoDesignException(String code, String... args) {
        super(getBusinessExceptionMessage(code, args));
        this.code = code;
        this.args = args;
    }

    private static String getBusinessExceptionMessage(String code, String... args) {
        if (args != null) {
            return code + "," + String.join(",", args);
        }
        return code;
    }

    public String getCode() {
        return code;
    }

    public String[] getArgs() {
        return args;
    }
}
